<?php
namespace app\manager\controller;

use think\Controller;

class Index extends Controller
{
    /**
     * 验证用户是否处于登录状态
     */
    protected function _initialize()
    {
        $user = session('Muser');
        if(!$user){
            $this->redirect('login/index');
        }
    }


    public function index()
    {
        $user = session('Muser');
        $nickname=db('manager')->where('m_name',$user)->value('m_nick');
        $this->assign('username',$nickname);
        $setinfo = db('setcont')->where('set_id','1')->find();
        $this->assign('setinfo',$setinfo);
        return $this->fetch();
    }

    /**
     * 网站设置
     */
    public function xt_set()
    {
        $setc = db('setcont')->where('set_id','1')->find();
        $this->assign('setc',$setc);
        return $this->fetch();
    }

    public function xt_set_do()
    {
        $param = input('post.');

        db('setcont')
            ->where('set_id', 1)
            ->update([
                'set_title'  => $param['set_title'],
                'set_keywords' => $param['set_keywords'],
                'set_discription' => $param['set_discription'],
                'set_rate' => $param['set_rate'],
                'set_dp_yiji' => $param['set_dp_yiji'],
                'set_dp_erji' => $param['set_dp_erji'],
                'set_dp_sanji' => $param['set_dp_sanji'],
                'set_dp_top' => $param['set_dp_top'],
                'set_zt_erji' => $param['set_zt_erji'],
                'set_zt_sanji' => $param['set_zt_sanji'],
                'set_jzbd_yiji' => $param['set_jzbd_yiji'],
                'set_jzbd_erji' => $param['set_jzbd_erji'],
                'set_jzbd_sanji' => $param['set_jzbd_sanji'],
                'set_jzbd_siji' => $param['set_jzbd_siji'],
                'set_jzbd_wuji' => $param['set_jzbd_wuji'],
                'set_jzbd_liuji' => $param['set_jzbd_liuji'],
                'set_jz_jd' => $param['set_jz_jd'],
                'set_jz_pp' => $param['set_jz_pp']
            ]);
        echo 200;
    }

}
